package com.fafa.swing.base;

import javax.swing.*;
import java.awt.*;

/**
 * @author : fafa
 * @version V1.0
 * @Project: SwingTest
 * @Package com.fafa.swing
 * @Description: JTableDemo
 * @date Date : 2019年11月26日 21:33
 */
public class JTableDemo extends JFrame {

    public JTableDemo(){
        setTitle("JTable表格组件示例");
        setBounds(500,500,400,300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container container = this.getContentPane();
        Object[][] tableData = new Object[5][8];
        for (int i = 0; i < 5; i++) {
            tableData[i][0] = "1000"+i;
            for (int j = 0; j < 8; j++) {
                tableData[i][j] = 0;
            }

        }
        String[] name = {"学号","软件工程","Java","网络","数据结构","数据库","总成绩","平均成绩"};
        JTable table = new JTable(tableData,name);
        table.setGridColor(Color.BLACK);
        //table.setShowGrid(true);
        container.add(new JScrollPane(table));
        setVisible(true);
    }

    public static void main(String[] args) {
        new JTableDemo();
    }
}
